package com.xb.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xb.model.domain.DistinctUser;
import com.xb.model.domain.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * (Users)表数据库访问层
 *
 * @author makejava
 * @since 2024-07-15 13:18:59
 */
@Mapper
public interface DistinctUserMapper extends BaseMapper<DistinctUser> {

    @Select("SELECT COUNT(*) FROM distinct_user WHERE phone = #{phone} AND name LIKE CONCAT('%', SUBSTRING(#{username}, -1))")
    int checkUserMatch(String phone, String username);

    @Select("CREATE INDEX idx_phone_name ON distinct_user (phone, name)")
    void createIndexes();

    @Select("DROP INDEX idx_phone_name ON distinct_user")
    void dropIndexes();
}

